<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>pushState</title>
</head>
<body>
    <section id="mySection">
    <button class="normal_btn">普通用户</button>
    <button class="normal_btn">管理员用户</button>
    </section>
    <hr>
    <div id="insertPoint"></div>
</body>
</html>
<script>
    document.getElementById("mySection").addEventListener("click",event=>{
        let url=event.target.innerHTML;
        let node=document.getElementById("insertPoint");
        let newUrl=location.href;
        if(location.href.indexOf("#")!=-1){
            let index=location.href.indexOf("#");
            newUrl=newUrl.substring(0,index);
            console.log(newUrl);
        }
        
        switch(url){
            case "普通用户":
            node.innerHTML="普通用户登录";
            url=newUrl+"#user";
            break;
            case "管理员用户":
            node.innerHTML="管理员用户登录";
            url=newUrl+"#manager";
            break;
        }
        history.pushState({},"",url);
    },false);
</script>